package so.sia.util;

public class NumberCheck {
	
	public static boolean numberCheck(String tmp){
		boolean isnum = true;
		int len = tmp.length();
		for (int i = 0 ; i < len ; i++){
			int c = tmp.charAt(i);
			if(c < 48 || c > 57){
				isnum = false;
				break;
			}
		}
		return isnum;
	}
	
	public static int nullToZero(String tmp){
		int num = 0;
		if (tmp != null){
			num = numberCheck(tmp)? Integer.parseInt(tmp) : 0;
		}
		return num;
	}
	
	public static int nullToOne(String tmp){
		int num = 1;
		if (tmp != null){
			num = numberCheck(tmp)? Integer.parseInt(tmp) : 1;
		}
		return num;
	}
	
}
